//
//  HotSellerTableViewCell.m
//  GiftItems
//
//  Created by lanou3g on 15/9/18.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "HotSellerTableViewCell.h"
#import "HotSellerModel.h"
@implementation HotSellerTableViewCell
// 利用Model赋值
-(void)setValueForAttributesWithModel:(HotSellerModel *)selModel {
    [self.picView sd_setImageWithURL:[NSURL URLWithString:selModel.cover_image_url] placeholderImage:[UIImage imageNamed:@"11.png"]];
    self.title.text = selModel.name;
    self.priceLabel.text = selModel.price;
    self.likeNum.text = [NSString stringWithFormat:@"%@",selModel.favorites_count];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self addSubViews];
    }
    return self;
}

- (void)addSubViews{
    // 设置物品的图片
    self.picView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 10, kWidth - 215, 130)];
    self.picView.layer.masksToBounds = YES;
    self.picView.layer.cornerRadius = 5;
    [self.contentView addSubview:self.picView];
    
    // 设置物品的标题
    self.title = [[UILabel alloc] initWithFrame:CGRectMake(kWidth - 175, 10, 150, 60)];
    [self setLabel:self.title];
    [self setLabel:self.title];
    
    self.icon = [[UIImageView alloc] initWithFrame:CGRectMake(kWidth - 102, 111, 20, 20)];
    self.icon.image = [UIImage imageNamed:@"FontAwesome_f157(0)_32"];
    [self.contentView addSubview:self.icon];
    
    // 设置价钱
    self.priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(kWidth - 85, 105, 80, 30)];
    [self setLabel:self.priceLabel];
    
    // 设置人气图标
    self.iconView = [[UIImageView alloc] initWithFrame:CGRectMake(kWidth - 185, 100, 40, 40)];
    self.iconView.image = [UIImage imageNamed:@"Entypo_2661(0)_64"];
    [self.contentView addSubview:self.iconView];
    
    // 设置人气数目
    self.likeNum = [[UILabel alloc] initWithFrame:CGRectMake(kWidth - 145, 105,60, 30)];
    [self setLabel:self.likeNum];
    
    // 设置底线
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(20, 149, kWidth - 45, 1)];
    lineView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:lineView];
    
}
// 设置Label的属性
- (void)setLabel:(UILabel *)label{
    label.textAlignment = NSTextAlignmentLeft;
    label.numberOfLines = 2;
    label.textColor = kRGB(255.0, 255.0,255.0);
    label.font = [UIFont boldSystemFontOfSize:13.0];
    [self.contentView addSubview:label];
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
